home *** CD-ROM | disk | FTP | other *** search
/ Champak 78 / (Vol 78) My Disc.iso / Games / okcukopek.swf / scripts / frame_4 / DoAction.as
Text File  |  2008-10-28  |  6KB  |  261 lines

  1. this.stop();
  2. FNscore = function(s, num)
  3. {
  4.    var _loc2_ = 1;
  5.    while(_loc2_ <= 6)
  6.    {
  7.       _root.menu_mc[s + _loc2_].gotoAndStop(Math.floor(num / Math.pow(10,_loc2_ - 1)) % 10 + 1);
  8.       _loc2_ = _loc2_ + 1;
  9.    }
  10. };
  11. v = 0;
  12. the = 0;
  13. vx = 0;
  14. vy = 0;
  15. level = 1;
  16. FNscore("l",level);
  17. mission = 2;
  18. FNscore("m",mission);
  19. score = 0;
  20. FNscore("s",score);
  21. life = 2;
  22. shot = false;
  23. move_ok = true;
  24. target_ok = true;
  25. game_ok = false;
  26. power_num = 4;
  27. this.power_bar.bar._yscale = 0;
  28. this.text_mc.gotoAndStop("start");
  29. this.blank_btn.useHandCursor = false;
  30. FNrotation = function()
  31. {
  32.    if(shot)
  33.    {
  34.       var _loc2_ = 2;
  35.       while(_loc2_ <= 4)
  36.       {
  37.          if(_loc2_ != 2)
  38.          {
  39.             this["mc" + _loc2_].mc.gotoAndStop(2);
  40.          }
  41.          _loc2_ = _loc2_ + 1;
  42.       }
  43.       if(move_ok)
  44.       {
  45.          this.mc2.mc._xscale = 80;
  46.          this.mc2.mc._yscale = 80;
  47.          this.mc2.mc._x += vx;
  48.          this.mc2.mc._y += vy;
  49.          if(this.mc2.mc._x > 700)
  50.          {
  51.             move_ok = false;
  52.             target_ok = false;
  53.             if(life == 0)
  54.             {
  55.                levelup_ok = false;
  56.                _loc2_ = 1;
  57.                while(_loc2_ <= 4)
  58.                {
  59.                   if(_loc2_ != 2)
  60.                   {
  61.                      this["mc" + _loc2_]._visible = false;
  62.                   }
  63.                   _loc2_ = _loc2_ + 1;
  64.                }
  65.                this.menu_mc.life.nextFrame();
  66.                this.mc.gotoAndStop("no");
  67.             }
  68.             else
  69.             {
  70.                life--;
  71.                this.menu_mc.life.nextFrame();
  72.                this.feedback_mc.gotoAndPlay(2);
  73.             }
  74.          }
  75.       }
  76.    }
  77.    else
  78.    {
  79.       _loc2_ = 1;
  80.       while(_loc2_ <= 4)
  81.       {
  82.          this["mc" + _loc2_].mc._rotation = Math.atan2(this["mc" + _loc2_]._ymouse,this["mc" + _loc2_]._xmouse) / 3.141592653589793 * 180;
  83.          if(this["mc" + _loc2_].mc._rotation <= -40)
  84.          {
  85.             this["mc" + _loc2_].mc._rotation = -39;
  86.          }
  87.          if(this["mc" + _loc2_].mc._rotation >= 20)
  88.          {
  89.             this["mc" + _loc2_].mc._rotation = 19;
  90.          }
  91.          _loc2_ = _loc2_ + 1;
  92.       }
  93.    }
  94. };
  95. FNhit = function()
  96. {
  97.    if(this.mc2.mc.hit.hitTest(this.target_mc.hit) && target_ok)
  98.    {
  99.       move_ok = false;
  100.       target_ok = false;
  101.       this.mc2.mc.m.gotoAndPlay("hit");
  102.       mission--;
  103.       FNscore("m",mission);
  104.       this.plus_mc.gotoAndPlay(2);
  105.       this.plus_mc._y = this.target_mc._y + 110;
  106.       if(this.power_bar.bar._yscale == 100)
  107.       {
  108.          score += 200;
  109.       }
  110.       else
  111.       {
  112.          score += 100;
  113.       }
  114.       FNscore("s",score);
  115.       if(mission == 0)
  116.       {
  117.          levelup_ok = true;
  118.          var _loc2_ = 1;
  119.          while(_loc2_ <= 4)
  120.          {
  121.             if(_loc2_ != 2)
  122.             {
  123.                this["mc" + _loc2_]._visible = false;
  124.             }
  125.             _loc2_ = _loc2_ + 1;
  126.          }
  127.          game_ok = false;
  128.          this.mc.gotoAndStop("ok");
  129.          this.levelup.gotoAndPlay(2);
  130.       }
  131.       else
  132.       {
  133.          this.feedback_mc.gotoAndPlay(2);
  134.       }
  135.       this.mc2.mc._x = 368;
  136.    }
  137. };
  138. this.target_mc._y = 215;
  139. yspeed = 10;
  140. FNtargetmove = function()
  141. {
  142.    if(target_ok)
  143.    {
  144.       if(this.target_mc._y + yspeed <= -15)
  145.       {
  146.          yspeed *= -1;
  147.       }
  148.       else if(this.target_mc._y + yspeed >= 225)
  149.       {
  150.          yspeed *= -1;
  151.       }
  152.       this.target_mc._y += yspeed;
  153.    }
  154. };
  155. FNpower = function()
  156. {
  157.    if(shot)
  158.    {
  159.       if(this.power_bar.bar._yscale == 100)
  160.       {
  161.          this.mc2.mc.gotoAndStop(3);
  162.       }
  163.       else
  164.       {
  165.          this.mc2.mc.gotoAndStop(2);
  166.       }
  167.    }
  168.    else if(this.power_bar.bar._yscale <= 100)
  169.    {
  170.       this.power_bar.bar._yscale += power_num;
  171.    }
  172.    else
  173.    {
  174.       this.power_bar.bar._yscale = 0;
  175.    }
  176. };
  177. FNshot = function()
  178. {
  179.    if(shot == false)
  180.    {
  181.       shot = true;
  182.       v = 30 + this.power_bar.bar._yscale / 5;
  183.       the = this.mc2.mc._rotation * 3.141592653589793 / 180;
  184.       vx = v * Math.cos(the);
  185.       vy = 1 * v * Math.sin(the);
  186.       arrow--;
  187.       FNscore("a",arrow);
  188.    }
  189. };
  190. FNreset = function()
  191. {
  192.    v = 0;
  193.    the = 0;
  194.    vx = 0;
  195.    vy = 0;
  196.    shot = false;
  197.    move_ok = true;
  198.    target_ok = true;
  199.    this.power_bar.bar._yscale = 0;
  200.    this.mc2.mc._x = 0;
  201.    this.mc2.mc._y = 0;
  202.    this.mc2.mc._xscale = 100;
  203.    this.mc2.mc._yscale = 100;
  204.    var _loc2_ = 2;
  205.    while(_loc2_ <= 4)
  206.    {
  207.       this["mc" + _loc2_].mc.gotoAndStop(1);
  208.       _loc2_ = _loc2_ + 1;
  209.    }
  210. };
  211. FNlevelup = function()
  212. {
  213.    FNreset();
  214.    var _loc2_ = 1;
  215.    while(_loc2_ <= 4)
  216.    {
  217.       if(_loc2_ != 2)
  218.       {
  219.          this["mc" + _loc2_].mc._rotation = 0;
  220.          this["mc" + _loc2_]._visible = true;
  221.       }
  222.       _loc2_ = _loc2_ + 1;
  223.    }
  224.    this.mc.gotoAndStop(1);
  225.    this.target_mc._y = 215;
  226.    this.levelup.gotoAndStop(1);
  227.    level++;
  228.    FNscore("l",level);
  229.    if(level < 8)
  230.    {
  231.       if(yspeed < 0)
  232.       {
  233.          yspeed -= 2;
  234.       }
  235.       else
  236.       {
  237.          yspeed += 2;
  238.       }
  239.    }
  240.    mission = level * 3;
  241.    FNscore("m",mission);
  242. };
  243. this.onEnterFrame = function()
  244. {
  245.    if(_root.vol == 1)
  246.    {
  247.       soundOn();
  248.    }
  249.    else if(_root.vol == 0)
  250.    {
  251.       soundOff();
  252.    }
  253.    if(game_ok)
  254.    {
  255.       FNpower();
  256.       FNrotation();
  257.       FNhit();
  258.       FNtargetmove();
  259.    }
  260. };
  261.